<template>
	<view class="invited-page"
		:style="{backgroundImage:'url('+$util.img('upload/uniapp/member/invite/page_bg@2x.png')+')'}">
		<view class="congratulations">恭喜!</view>
		<view class="content_text">{{info.nickname}}邀请您开通商户</view>
		<view class="content_text">您享有专属快速入驻通道，立即入驻!</view>
		<view class="but" @click.stop="buttonEvent">{{token ? '立即入驻' : '您还没登录，立即登录'}}</view>
		<ns-login ref="login"></ns-login>
		<loading-cover ref="loadingCover"></loading-cover>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				token: '',
				suid: '',
				info: {}
			}
		},
		onLoad(opts) {
			if (opts.suid) {
				this.suid = opts.suid;
				this.getInvitedInfo();
			}
		},
		onShow() {
			this.token = uni.getStorageSync('token');
		},
		methods: {
			/* 获取邀请人信息 */
			getInvitedInfo() {
				this.$api.sendRequest({
					url: '/api/member/getmemberInfo',
					data: {
						member_id: this.suid
					},
					success: res => {
						if (res.code == 0) {
							this.info = res.data;
						} else {
							this.$util.showToast({
								title: res.message
							});
						}
						if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
					},
					fail: err => {
						if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
					}
				})
			},
			/* 按钮事件 */
			buttonEvent() {
				if (this.token) { //立即入驻
					this.$util.redirectTo('/otherpages/webview/webview', {
						link: encodeURIComponent(this.info.jumpurl)
					});
				} else { //登录
					this.$refs.login.open('/businesscenter/invited-page?suid=' + this.suid);
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.invited-page {
		width: 750rpx;
		height: 1624rpx;
		background-size: 100% 100%;
		padding: 296rpx 64rpx 0 64rpx;

		.congratulations {
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 64rpx;
			color: #222222;
			line-height: 90rpx;
			margin-bottom: 52rpx;
		}

		.content_text {
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 32rpx;
			color: #222222;
			line-height: 44rpx;
		}

		.but {
			margin-top: 716rpx;
			width: 100%;
			height: 88rpx;
			background: #004FC6;
			border-radius: 80rpx 80rpx 80rpx 80rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #FFFFFF;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}

	view {
		box-sizing: border-box;
	}
</style>